<?php

function my_keywords () {
    $str = '';
    if (is_home () || is_front_page ()) {
	$str = 'Liste, von, Keywords, durch, Komma, getrennt';
    } elseif (is_single ()) {
	$keywords = array ();
	$arr = get_the_tags ();
        if ($arr) {
            foreach ($arr as $elem) {
                $keywords[] = strtolower ($elem->name);
            }
        }
        $arr = get_the_category ();
        if ($arr) {
            foreach ($arr as $elem) {
                $keywords[] = strtolower ($elem->name);
            }
        }
        $keywords = array_unique ($keywords);
	if (count ($keywords) > 10) $keywords = array_slice ($keywords, 0, 10);
	$str = implode (', ', $keywords);
    }
    if (!empty ($str)) {

?>
<meta name="keywords" content="<?php echo htmlspecialchars ($str); ?>"/>
<?php

    }
}
add_action ('wp_head', 'my_keywords');

?>
